﻿using App.Code;
using App.Entity;
using App.IServices;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace AppAit.Areas.SystemManage.Controllers
{
    /// <summary>
    /// 岗位管理
    /// </summary>
    public class DutyController : ControllerBase
    {
        IDutyServices _duty;
        public DutyController(IDutyServices duty)
        {
            _duty = duty;
        }

        /// <summary>
        /// 列表
        /// </summary>
        /// <param name="keyword">岗位名称或岗位编号</param>
        [HttpGet]
        [HandlerAjaxOnly]
        public ActionResult GetGridJson(string keyword)
        {
            var data = _duty.GetList(keyword);
            return Content(data.ToJson());
        }
        /// <summary>
        /// 绑定表单
        /// </summary>
        /// <param name="keyValue">主键</param>
        /// <returns></returns>
        [HttpGet]
        [HandlerAjaxOnly]
        public ActionResult GetFormJson(string keyValue)
        {
            var data = _duty.GetForm(keyValue);
            return Content(data.ToJson());
        }
        /// <summary>
        /// 添加/编辑岗位
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        [HandlerAjaxOnly]
        [ValidateAntiForgeryToken]
        public ActionResult SubmitForm(Sys_Role roleEntity, string keyValue)
        {
            _duty.SubmitForm(roleEntity, keyValue);
            return Success("操作成功。");
        }
        /// <summary>
        /// 删除
        /// </summary>
        [HttpPost]
        [HandlerAjaxOnly]
        [HandlerAuthorize]
        [ValidateAntiForgeryToken]
        public ActionResult DeleteForm(string keyValue)
        {
            _duty.DeleteForm(keyValue);
            return Success("删除成功。");
        }
    }
}